Projet Chamois

1 Chargement des librairies


library(tidyverse)
library(corrplot)
library(lmerTest)
library(ade4)
library(splines)
library(car)
library(plotly)
library(DT)

2 Prealable


2.1 Import des donnees

setwd(".")
load('cham.Rdata')
datatable(cham, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )

2.2 Creation des variables age et longevite (long)

age<-cham$year-cham$coh
long<-cham$ydth-cham$coh
cham2<-cbind(cham, age, long)

3 Lien fecondite annuelle et age des femelles


3.1 Représentation graphique des données

3.1.1 Représentation par classe d’age

cham_age<-cham2 %>% 
  group_by(age) %>%
  dplyr::summarise(totnaissance= sum(fec), taillepop=n(), fecperind=totnaissance/n()*100)

plot1 <- ggplot(cham_age, aes(x=age, y=fecperind)) + 
    geom_bar(color="blue", fill=rgb(0.1,0.4,0.5,0.7), stat = "identity") + 
    labs(title = "Fécondité de la population en fonction de l'age",x="Age", y="Fécondité annuelle de la population") + 
    theme(plot.title = element_text(hjust = 0.5)) + 
    geom_smooth()
ggplotly(plot1)

3.1.2 Representation sans grouper par classe d’age

3.1.2.1 Utilisation de la fonction jitter

plot2 <- ggplot(cham2, aes(x=age, y=fec)) + 
    geom_jitter(width = 0.55, height = 0) + 
    labs(title = "Fécondité en fonction de l'age",x="Age", y="Fécondité") +
    theme(plot.title = element_text(hjust = 0.5)) + 
    geom_smooth()
ggplotly(plot2)

3.1.2.2 Utilisation de la fonction geom_count

plot3 <- ggplot(cham2, aes(x=age, y=fec)) +
    geom_count() + 
    labs(title = "Fécondité en fonction de l'age",x="Age", y="Fécondité")+
    theme(plot.title = element_text(hjust = 0.5))
ggplotly(plot3)

3.2 Analyse statistique du lien entre fecondite annuelle et l’age des femelles

3.2.1 Modèles de régression lineaire generalise avec effets aléatoires


3.2.1.1 First

glm1 <- glmer(fec ~ age + (1| id),data=cham2, family = binomial)
summary(glm1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ age + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1775.1   1790.7   -884.6   1769.1     1325 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6411 -1.1386  0.6819  0.7903  1.0477 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2129   0.4614  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.58024    0.15766   3.680 0.000233 ***
## age         -0.01703    0.01560  -1.092 0.275013    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##     (Intr)
## age -0.903
Anova(glm1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: fec
##      Chisq Df Pr(>Chisq)
## age 1.1916  1      0.275
surdispersion_glm1 <- 1775/1325;surdispersion_glm1
## [1] 1.339623

AIC = 1775 et p-value = 0.27.



Pas de surdispersion observee.

3.2.1.2 Second

glm2 <- glmer(fec ~ year + (1| id),data=cham2, family = binomial)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.290051 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?
summary(glm2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ year + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1776.3   1791.8   -885.1   1770.3     1325 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6666 -1.1423  0.6818  0.7912  1.0706 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2173   0.4662  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  6.5452438  1.3195532   4.960 7.04e-07 ***
## year        -0.0030515  0.0006584  -4.634 3.58e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## year -0.999
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 0.290051 (tol = 0.002, component 1)
## Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

3.2.1.3 Third

glm3 <- glmer(fec ~ age+ year + (1| id),data=cham2, family = binomial)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.292699 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?
summary(glm3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ age + year + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1777.1   1797.9   -884.6   1769.1     1324 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6486 -1.1413  0.6819  0.7907  1.0438 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2128   0.4613  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##               Estimate Std. Error z value Pr(>|z|)  
## (Intercept)  2.8329285  1.3214401   2.144   0.0320 *
## age         -0.0167623  0.0155980  -1.075   0.2825  
## year        -0.0011244  0.0006564  -1.713   0.0867 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr) age   
## age  -0.095       
## year -0.993 -0.013
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 0.292699 (tol = 0.002, component 1)
## Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

3.2.1.4 Fourth

glm4 <- glmer(fec ~ age*year + (1| id),data=cham2, family = binomial)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 3.403 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?
summary(glm4)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ age * year + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1779.1   1805.1   -884.6   1769.1     1323 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6675 -1.1401  0.6837  0.7906  1.0334 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2095   0.4577  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  1.082e+01  1.319e+00   8.207 2.26e-16 ***
## age         -8.721e-01  1.936e-02 -45.053  < 2e-16 ***
## year        -5.109e-03  6.551e-04  -7.799 6.23e-15 ***
## age:year     4.265e-04  8.441e-06  50.533  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##          (Intr) age    year  
## age      -0.073              
## year     -0.993 -0.002       
## age:year -0.007 -0.593 -0.014
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 3.403 (tol = 0.002, component 1)
## Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

3.2.1.5 Fifth

glm5<- glmer(fec ~ age + (1| id) + (1| year),data=cham2, family = binomial)
summary(glm5)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ age + (1 | id) + (1 | year)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1750.5   1771.3   -871.2   1742.5     1324 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.9922 -1.0487  0.6251  0.7479  1.4398 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2402   0.4901  
##  year   (Intercept) 0.2214   0.4705  
## Number of obs: 1328, groups:  id, 217; year, 27
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.65014    0.18973   3.427 0.000611 ***
## age         -0.02212    0.01624  -1.362 0.173287    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##     (Intr)
## age -0.779
Anova(glm5)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: fec
##      Chisq Df Pr(>Chisq)
## age 1.8543  1     0.1733
surdispersion_glm5 <- 1750/1324;surdispersion_glm5
## [1] 1.321752

AIC = 1750 et p-value = 0.17.



Pas de surdispersion observee.

4 Variation de la fecondite annuelle en fonction du temps


4.1 Représentation graphique des données

4.1.1 Représentation graphique par annee

cham_ans = cham2 %>% 
  group_by(year) %>% 
  dplyr::summarise(totnaissance= sum(fec), taillepop=n(), agemoyen=mean(age)) %>% 
  mutate(fecperind=totnaissance/taillepop)%>% 
  mutate(ratiofecage=fecperind/agemoyen)
plot4 <- ggplot(cham_ans, aes(x=year, y=fecperind)) +
    geom_bar(color="blue", fill=rgb(0.1,0.4,0.5,0.7), stat = "identity") + 
    labs(title = "Fécondité de la population en fonction des annees",x="Annees", y="Fécondité annuelle de la population") +
    theme(plot.title = element_text(hjust = 0.5)) +
    geom_smooth(); plot4

plot5 <- ggplot(data = cham_ans, aes(x = year,y=agemoyen))+
     labs(title = "Age de la population en fonction des annees",x="Annees", y="Age moyen") +
    theme(plot.title = element_text(hjust = 0.5)) +
    geom_point(); plot5

4.1.2 Représentation graphique sans grouper par annee

plot6 <- ggplot(cham2, aes(x=year, y=fec)) + 
    labs(title = "Fécondité en fonction des annees",x="Annees", y="Fécondité") +
    geom_jitter(width = 0.55, height = 0) +
    theme(plot.title = element_text(hjust = 0.5)); plot6

plot7 <- ggplot(cham2, aes(x=year, y=fec)) + 
    geom_count() + 
    labs(title = "Fécondité en fonction des annees",x="Annees", y="Fécondité") +
    theme(plot.title = element_text(hjust = 0.5)); plot7

plot8 <- ggplot(data = cham_ans, aes(x = year,y=agemoyen))+
   labs(title = "Age de la population en fonction des annees",x="Annees", y="Age moyen") +
    theme(plot.title = element_text(hjust = 0.5)) +
    geom_point(); plot8

4.2 Analyse statistique du lien entre fécondité annuelle et temps

4.2.1 Modèles de régression lineaire generalise avec effets aléatoires


4.2.1.1 First

glm6 <- glmer(fec ~ year + (1| id),data=cham2, family = binomial)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.290051 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?
summary(glm6)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ year + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1776.3   1791.8   -885.1   1770.3     1325 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6666 -1.1423  0.6818  0.7912  1.0706 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2173   0.4662  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  6.5452438  1.3195532   4.960 7.04e-07 ***
## year        -0.0030515  0.0006584  -4.634 3.58e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## year -0.999
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 0.290051 (tol = 0.002, component 1)
## Model is nearly unidentifiable: very large eigenvalue
##  - Rescale variables?
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

4.2.1.2 Second

Transformation de la variable year en variable normee reduite

year_scale<-scale(cham2$year, center=TRUE, scale= TRUE)
glm7 <- glmer(fec ~ year_scale + (1| id),data=cham2, family = binomial)
summary(glm7)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ year_scale + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1776.3   1791.8   -885.1   1770.3     1325 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6666 -1.1423  0.6818  0.7912  1.0706 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2173   0.4662  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.42505    0.06783   6.266  3.7e-10 ***
## year_scale  -0.01823    0.06530  -0.279     0.78    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## year_scale -0.001
surdispersion_glm7 <- 1776/1325;surdispersion_glm7
## [1] 1.340377

AIC = 1776 et p-value = 0.78.



Pas de surdispersion observee.

4.2.1.3 Third

glm8 <- glmer(fec ~ year_scale+age + (1| id),data=cham2, family = binomial)
summary(glm8)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ year_scale + age + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1777.1   1797.9   -884.6   1769.1     1324 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6486 -1.1413  0.6819  0.7907  1.0438 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2128   0.4613  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.577851   0.159379   3.626 0.000288 ***
## year_scale  -0.006749   0.066039  -0.102 0.918604    
## age         -0.016762   0.015809  -1.060 0.289001    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) yr_scl
## year_scale  0.146       
## age        -0.905 -0.163
surdispersion_glm8 <- 1777/1324;surdispersion_glm8
## [1] 1.342145

4.2.1.4 Fourth

glm9 <- glmer(fec ~ year_scale*age + (1| id),data=cham2, family = binomial)
summary(glm9)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ year_scale * age + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1779.1   1805.1   -884.6   1769.1     1323 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6689 -1.1399  0.6839  0.7907  1.0327 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.2092   0.4574  
## Number of obs: 1328, groups:  id, 217
## 
## Fixed effects:
##                 Estimate Std. Error z value Pr(>|z|)    
## (Intercept)     0.575862   0.159548   3.609 0.000307 ***
## year_scale     -0.032348   0.161967  -0.200 0.841699    
## age            -0.016602   0.015815  -1.050 0.293816    
## year_scale:age  0.002755   0.015923   0.173 0.862625    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) yr_scl age   
## year_scale   0.124              
## age         -0.906 -0.119       
## year_scal:g -0.072 -0.913  0.059
surdispersion_glm9 <- 1779/1323;surdispersion_glm9
## [1] 1.344671

5 Lien entre fecondite totale et longevite des animaux


5.1 Représentation graphique des données

5.1.1 Representation de la fecondite totale par annee

cham_id = cham2 %>% 
  group_by(id) %>% 
  dplyr::summarise(feconditetotale= sum(fec), long=long, pds=pds, anneetot=(ydth-min(year)+1), MinAn=min(year), MaxAn=max(year), AgePds=min(age)) %>%
  unique()%>%
  mutate(fecrelative=feconditetotale/anneetot)%>%
  drop_na(long)
plot9 <- ggplot(cham_id, aes(x=long, y=feconditetotale)) +
    geom_point(color="blue", fill=rgb(0.1,0.4,0.5,0.7)) + 
     labs(title = "Fecondite totale en fonction de la longevite",x="Longevite", y="Fecondite totale") +
    theme(plot.title = element_text(hjust = 0.5)) +
    geom_smooth(); plot9
ggplotly(plot9)
plot10 <- ggplot(data = cham_id, aes(x=long, y=fecrelative))+
    geom_point(color="blue", fill=rgb(0.1,0.4,0.5,0.7)) +
    labs(title = "Fecondite sur le nombre d'annees suivies en fonction de la longevite",x="Longevite", y="Fecondite relative au nombre d'annees suivies") +
    geom_smooth() +
    theme(plot.title = element_text(hjust = 0.5)); plot10

plot11 <-ggplot(cham_id, aes(x=long, y=feconditetotale)) +
    geom_count() +
    geom_smooth()
ggplotly(plot11)
plot12 <- ggplot(cham_id, aes(x=long, y=feconditetotale)) +
    geom_jitter(width = 0.25, height = 0.25)+
    geom_smooth()
ggplotly(plot12)

5.2 Analyse statistique du lien entre la fécondité annuelle et la longevite

5.2.1 Tests de modèles de régression lineaire generalise avec effets aléatoires


5.2.1.1 First

lm1 <- lm(feconditetotale~long, data = cham_id)
summary(lm1)
## 
## Call:
## lm(formula = feconditetotale ~ long, data = cham_id)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.2342 -1.6839 -0.4381  1.6806  8.5451 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.38772    0.64837   0.598    0.551    
## long         0.25420    0.05203   4.886 2.47e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.715 on 161 degrees of freedom
## Multiple R-squared:  0.1291, Adjusted R-squared:  0.1237 
## F-statistic: 23.87 on 1 and 161 DF,  p-value: 2.468e-06
plot(lm1)

hist(resid(lm1))

lm2 <- lm(feconditetotale~log(long), data = cham_id)
summary(lm2)
## 
## Call:
## lm(formula = feconditetotale ~ log(long), data = cham_id)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.3527 -1.8484 -0.3931  1.6565  8.6115 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -2.9773     1.2571  -2.368    0.019 *  
## log(long)     2.6567     0.5178   5.131 8.22e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.697 on 161 degrees of freedom
## Multiple R-squared:  0.1405, Adjusted R-squared:  0.1352 
## F-statistic: 26.32 on 1 and 161 DF,  p-value: 8.223e-07
plot(lm2)

lm2bis <- lm(sqrt(feconditetotale)~long, data = cham_id)
summary(lm2bis)
## 
## Call:
## lm(formula = sqrt(feconditetotale) ~ long, data = cham_id)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.34105 -0.45584  0.02148  0.60739  1.70711 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.88677    0.19418   4.567 9.79e-06 ***
## long         0.06323    0.01558   4.058 7.70e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.813 on 161 degrees of freedom
## Multiple R-squared:  0.09279,    Adjusted R-squared:  0.08716 
## F-statistic: 16.47 on 1 and 161 DF,  p-value: 7.699e-05
plot(lm2bis)

cham_id2 <- cham_id[cham_id$feconditetotale!=0,]
lm3 <- lm(log(feconditetotale)~(log(long)), data = cham_id2)
summary(lm3)
## 
## Call:
## lm(formula = log(feconditetotale) ~ (log(long)), data = cham_id2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.47197 -0.49128  0.05571  0.57801  1.44308 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.0820     0.3588  -3.015  0.00303 ** 
## log(long)     0.8836     0.1476   5.988  1.6e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6917 on 145 degrees of freedom
## Multiple R-squared:  0.1983, Adjusted R-squared:  0.1927 
## F-statistic: 35.86 on 1 and 145 DF,  p-value: 1.596e-08
plot(lm3)

lm4 <- lm(log(feconditetotale+1)~(long), data = cham_id2)
summary(lm4)
## 
## Call:
## lm(formula = log(feconditetotale + 1) ~ (long), data = cham_id2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.09994 -0.33845 -0.02604  0.41327  1.17593 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.65085    0.13462   4.835 3.36e-06 ***
## long         0.06346    0.01087   5.839 3.32e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5062 on 145 degrees of freedom
## Multiple R-squared:  0.1903, Adjusted R-squared:  0.1848 
## F-statistic: 34.09 on 1 and 145 DF,  p-value: 3.316e-08
plot(lm4)

lm6 <- lm(fecrelative~long, data = cham_id)
summary(lm6)
## 
## Call:
## lm(formula = fecrelative ~ long, data = cham_id)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.57254 -0.23862 -0.00058  0.21381  0.85628 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  5.727e-01  7.239e-02   7.911 3.87e-13 ***
## long        -4.066e-05  5.809e-03  -0.007    0.994    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3031 on 161 degrees of freedom
## Multiple R-squared:  3.044e-07,  Adjusted R-squared:  -0.006211 
## F-statistic: 4.9e-05 on 1 and 161 DF,  p-value: 0.9944
plot(lm6)

lm6 <- lm(log(fecrelative)~long, data = cham_id2)
summary(lm6)
## 
## Call:
## lm(formula = log(fecrelative) ~ long, data = cham_id2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.53235 -0.29253  0.06901  0.30220  0.90812 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.59059    0.11470  -5.149 8.38e-07 ***
## long         0.00435    0.00926   0.470    0.639    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4313 on 145 degrees of freedom
## Multiple R-squared:  0.001519,   Adjusted R-squared:  -0.005367 
## F-statistic: 0.2207 on 1 and 145 DF,  p-value: 0.6392
plot(lm6)

glm9 <- glm(data=cham_id, feconditetotale~long, family="poisson")
summary(glm9)
## 
## Call:
## glm(formula = feconditetotale ~ long, family = "poisson", data = cham_id)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.8642  -1.1470  -0.4008   0.8318   3.4669  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.29098    0.14186   2.051   0.0402 *  
## long         0.07476    0.01039   7.198 6.09e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 397.41  on 162  degrees of freedom
## Residual deviance: 345.61  on 161  degrees of freedom
## AIC: 783.81
## 
## Number of Fisher Scoring iterations: 5
glm10 <- glm(data=cham_id, feconditetotale~long, family="quasipoisson")
summary(glm10)
## 
## Call:
## glm(formula = feconditetotale ~ long, family = "quasipoisson", 
##     data = cham_id)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.8642  -1.1470  -0.4008   0.8318   3.4669  
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.29098    0.20088   1.449    0.149    
## long         0.07476    0.01471   5.083 1.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasipoisson family taken to be 2.005336)
## 
##     Null deviance: 397.41  on 162  degrees of freedom
## Residual deviance: 345.61  on 161  degrees of freedom
## AIC: NA
## 
## Number of Fisher Scoring iterations: 5

6 Lien entre fecondite annuelle et longevite des animaux


6.1 Représentation graphique des données

plot10 <- ggplot(cham2, aes(x=long, y=fec)) +
    geom_count() + 
    labs(title = "Fécondité en fonction de la longevite",x="Longevite", y="Fécondité")+
    theme(plot.title = element_text(hjust = 0.5)); plot10

plot14 <- ggplot(cham2, aes(x=long, y=fec)) +
    geom_count() + 
    labs(title = "Fécondité en fonction de la longevite",x="Longevite", y="Fécondité")+
    theme(plot.title = element_text(hjust = 0.5)); plot10

cham_long<-cham2 %>% 
  group_by(long) %>%
  dplyr::summarise(totnaissance= sum(fec), taillepop=n())

plot15 <- ggplot(cham_long, aes(x=long, y=totnaissance/taillepop*100)) + 
    geom_bar(color="blue", fill=rgb(0.1,0.4,0.5,0.7), stat = "identity") + 
    labs(title = "Fécondité de la population en fonction de la longevite",x="Longevite", y="Fécondité annuelle de la population") + 
    theme(plot.title = element_text(hjust = 0.5)) + 
    geom_smooth()
ggplotly(plot15)

6.2 Analyse statistique du lien entre fecondite annuelle et longevite des femelles

6.2.1 Modèles de régression lineaire generalise avec effets aléatoires


6.2.1.1 First

glm11 <- glmer(fec ~ long + (1| id),data=cham2, family = binomial)
summary(glm11)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fec ~ long + (1 | id)
##    Data: cham2
## 
##      AIC      BIC   logLik deviance df.resid 
##   1231.2   1245.6   -612.6   1225.2      917 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7987 -1.0648  0.6503  0.7841  1.2074 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  id     (Intercept) 0.3248   0.5699  
## Number of obs: 920, groups:  id, 163
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.23862    0.29226   0.816    0.414
## long         0.01167    0.02217   0.526    0.599
## 
## Correlation of Fixed Effects:
##      (Intr)
## long -0.955
Anova(glm11)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: fec
##       Chisq Df Pr(>Chisq)
## long 0.2771  1     0.5986

7 Lien entre fecondite totale et poids


7.1 Représentation graphique des données

plot15 <- ggplot(cham_id, aes(x=AgePds, y=pds)) + 
    geom_point(color="blue", fill=rgb(0.1,0.4,0.5,0.7)) + 
    geom_smooth();plot15

lm13 <- lm(pds ~ AgePds,data=cham_id)
summary(lm13)
## 
## Call:
## lm(formula = pds ~ AgePds, data = cham_id)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.8357  -1.8365   0.5625   2.3637   6.8643 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 16.83507    0.65013  25.895  < 2e-16 ***
## AgePds       0.60022    0.08212   7.309 2.51e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.35 on 129 degrees of freedom
##   (32 observations effacées parce que manquantes)
## Multiple R-squared:  0.2928, Adjusted R-squared:  0.2874 
## F-statistic: 53.42 on 1 and 129 DF,  p-value: 2.506e-11
cham_id3 <- cham_id[cham_id$AgePds>3,]
lm14 <- lm(pds ~ AgePds,data=cham_id3)
summary(lm14)
## 
## Call:
## lm(formula = pds ~ AgePds, data = cham_id3)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2795 -1.2143 -0.0396  1.2404  4.2205 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 21.47517    0.59786  35.920   <2e-16 ***
## AgePds       0.14493    0.06593   2.198   0.0304 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.949 on 94 degrees of freedom
##   (18 observations effacées parce que manquantes)
## Multiple R-squared:  0.0489, Adjusted R-squared:  0.03878 
## F-statistic: 4.832 on 1 and 94 DF,  p-value: 0.03038
plot16 <- ggplot(cham_id3, aes(x=AgePds, y=pds)) + 
    geom_point(color="blue", fill=rgb(0.1,0.4,0.5,0.7)) + 
    geom_smooth();plot16

lm15 <- lm(feconditetotale ~ pds,data=cham_id3)
summary(lm15)
## 
## Call:
## lm(formula = feconditetotale ~ pds, data = cham_id3)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.0239 -1.8415 -0.7401  1.1643  5.7444 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   0.2439     2.6245   0.093    0.926
## pds           0.1158     0.1151   1.006    0.317
## 
## Residual standard error: 2.23 on 94 degrees of freedom
##   (18 observations effacées parce que manquantes)
## Multiple R-squared:  0.01066,    Adjusted R-squared:  0.0001331 
## F-statistic: 1.013 on 1 and 94 DF,  p-value: 0.3169